package vsqlbuilder.gui;

import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;

public class Tabs extends JTabbedPane {
	static final long serialVersionUID = 0L; // TODO [low]: temporary fix,
												// should be change to correct
												// one
	public TabQuery panel1;
	//TODO [low]: mix panel2 & panel2inside in one class
	public JScrollPane panel2;
	public TabRestrictions panel2inside;

	public Tabs(MainController controller) {
		
		panel1 = new TabQuery();
		this.addTab("SQL", null, panel1, "In this tab is generate the SQL statment create with Visual SQL Builder");

		panel2 = new JScrollPane();
		panel2inside = new TabRestrictions(controller);
		panel2.getViewport().add(panel2inside);

		this.addTab("Restrict",null,panel2,"Restrictions for SQL retrieve rows");
		//TODO [low]: erase all items not needed

		JComponent panel3 = makeTextPanel("Group");
		this
				.addTab("Group", null, panel3,
						"Requested function is not implemented in this version. [Group by Clause]");

		JComponent panel4 = makeTextPanel("Restrict Groups");
		panel4.setPreferredSize(new Dimension(410, 50));
		this
				.addTab("Restrict Groups", null, panel4,
						"Requested function is not implemented in this version. [Having Clause]");

		JComponent panel5 = makeTextPanel("Order");
		panel5.setPreferredSize(new Dimension(410, 50));
		this
				.addTab("Order", null, panel5,
						"Requested function is not implemented in this version. [Order Clause]");

		this.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
	}

	// TODO[low]: function only for tab panned test purpose, delete if no needed
	// in future
	protected JComponent makeTextPanel(String text) {
		JPanel panel = new JPanel(false);
		JLabel filler = new JLabel(text);
		filler.setHorizontalAlignment(JLabel.CENTER);
		panel.setLayout(new GridLayout(1, 1));
		panel.add(filler);
		return panel;
	}

}
